The present invention relates to method and apparatus for controlling a data base in which resources are shared by parallelly executed tasks, and more particularly to a method and apparatus for exclusively controlling a data base which assures integrity of data included in the resources and which is suitable to a data base management system which requires a high response for data handling.
If data included in resources which are shared by tasks, such as a data base in a computer system are simultaneously updated or referenced by a plurality of parallelly executed tasks, the data may be destroyed (destruction of data integrity) or an error may be included in processing results of the tasks.
In a prior art data base managment system, a mechanism (exclusive control mechanism) is provided to prevent a plurality of tasks from simultaneously handling the data base or a resource which is a portion of the data base.
In a conventional exclusive control system, the data base or a portion thereof (resource) is locked only for a period necessary for one task and the handling of the locked resource by other tasks is delayed until the resource is unlocked. (Locking system).
However, where a plurality of resources are used and if each task sequentially locks the resources as required without unlocking the resources, one task may attempt to lock the resource locked by other task and waits for unlocking of the task (deadlock). In this case, both tasks may not be executed.
Thus, in the data base management system which effects the exclusive control by the locking method, the exclusive control mechanism is provided with means for preventing the deadlock.
In the prior art method for preventing the deadlock, the occurrence of the deadlock is detected and a normal state is restored (back-out system), or locking of resources which one task uses are collectively controlled to prevent the deadlock (bundle locking system).
In the bundle locking system, all resources which the task may need in a series of processings are collectively locked, and the locked resource does not request locking to other resources. In this system, the deadlock is prevented because resource wait status in which the task waits for unlocking of the resource locked by another task does not occur.
In the bundle locking system, however, when a task which uses a plurality of resources is started, all resources related to the task are locked even if only one of the resources is accessed. As a result, the lock period of the resources is long and the parallel processing ability of the tasks (i.e., the number of tasks which can be executed in parallel) is lowered. That is, even when one task accesses only a portion of the collectively locked resources, the other tasks cannot access the nonaccessed resources of the collectively locked resources. Further, the resources which are not certain whether they are required or not until the task is executed must also be locked. Accordingly, the lock area is larger than that when the resources are individually locked. This also decreases the parallel processing ability of the tasks. Further, since a user (developer of a program) must expressedly specify the resources to be locked, errors may be easily included during the development of the program and the reliability and the productivity of the program may be decreased.
On the other hand, in the back-out system, each task locks the resources which it needs, and if the deadlock occurs between the resources, the processing for all tasks is stopped and the deadlock is released. In this system, so long as the deadlock does not occur, the parallel processing ability of the tasks is higher than that of the bundle locking system. However, once the deadlock occurs, a long time is required before recovery from the deadlock status. In the recovery from the deadlock status in the back-out system, the processing of one of the tasks with which the deadlock occurs is invalidated so that the locked resource is forceably unlocked. However, this is not sufficient because the task invalidated has handled the resources before the deadlock occurs and such resources should be recovered to the state prior to the execution of the task. Further, since there is a possibility that the resource to be recovered has been unlocked and another task is executed by using that resource, such a task should also be invalidated (back-out chaining). Thus, in the back-out system, the amount of information processed for recovery is large and the recovery time is long. The invalidated task should be reexecuted and the response of the task is lowered in average. While a method to prevent the back-out chaining has been proposed, the deadlock still occurs and a considerable time is required to recover from the deadlock status in the back-out system.
It is thus seen that a system is necessary in which each task sequentially locks required resources and yet deadlock is prevented, such that processing time is shorter than that in the bundle lock system or the back-out system.